/*
 *  $Id: AshesToAshes.cs 1051 2010-05-18 22:10:41Z thenn.erannor $
 *	This file is a part of Ragima CCG.
 *	(C) 2008 Ragima development group.
 *
 *	Licensed under the terms of the GNU GPL License version 2.
 *
 */

namespace Ragima.Cards001.Light.Spells {
    public class AshesToAshes: TargetEnchantmentCard<Creature> {
        public AshesToAshes(): base("001_l_s_ashes_to_ashes") {
            Level = CompleteLevel.ReadyForTest;
            Element = ElementType.Light;
            Value = 100;
            Target = new CreatureTarget(GetTargetPhrase(), true, true, IsResurrectOrUndead);
            AddManaCost(ElementType.Light, 3);
        }

        private static bool IsResurrectOrUndead(TargetRequest request, Creature cr) {
            return cr.HasFlag<Affects.Resurrect>() || cr.IsUndead;
        }

        protected override EnchantmentAffect CreateEnchantment() {
            return new AshesToAshesAffect();
        }

        private class AshesToAshesAffect: EnchantmentAffect<AshesToAshes> {
            public AshesToAshesAffect() {
                Add(new Affects.OnDamage(Damage, AffectSummaryType.Local));
            }

            private void Damage(AbstractObject target, DamageInfo damage) {
                target.InstantDeath();
            }
        }
    }
}
